package com.yaoli.ajob;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by siemens on 4/5/2017.
 */
public class _539_MinimumTimeDifference {
    public static void main(String[] args) throws FileNotFoundException {
        _539_MinimumTimeDifference minimumTimeDifference = new _539_MinimumTimeDifference();

        BufferedReader reader = new BufferedReader(new FileReader(new File("C:\\Users\\siemens\\Desktop\\New Text Document (4).txt")));
        String str [] = null;

        try {
            String res = reader.readLine();
            str = res.split("\",\"");
        } catch (IOException e) {
            e.printStackTrace();
        }


        List<String> list =new ArrayList<String>();
        for (int i = 0; i < str.length -10000; i++) {
            if(!str[i].equals("")){
                list.add(str[i]);
            }
        }
        long b = System.currentTimeMillis();
        minimumTimeDifference.findMinDifference(list);
        long e = System.currentTimeMillis();
        System.out.println(e - b);
    }


    public int findMinDifference(List<String> timePoints) {
        Map<String,Integer> map = new HashMap<String,Integer>() ;
        int res = Integer.MAX_VALUE;
        for(int i = 0 ; i < timePoints.size() ; i ++){
            for(int j = i ; j < timePoints.size() ; j++){
                if(i != j){
//                    if (!map.containsKey(timePoints.get(i))) {
//                        map.put(timePoints.get(i),)
//                    }
//                    String [] seta = a.split(":");
//                    String [] setb = b.split(":");

//                    int numa = Integer.valueOf(seta[0])*60 + Integer.valueOf(seta[1]);
//                    int numb = Integer.valueOf(setb[0])*60 + Integer.valueOf(setb[1]);
//
//                    int temp = calc(numa,numb);
//                    if(temp < res) {
//                        res = temp;
//                    }
                }
            }
        }

        return res;
    }

    public int calc(int numa,int numb){
        if(numa > numb){
            int temp = numa;
            numa = numb;
            numb = temp;
        }

        int res = numb - numa;

        if(numa + 1440 - numb < res){
            res = numa + 1440 - numb;
        }
        return res;
    }
}
